package org.bite.lesson02;

public class Demo_203 {
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
           for(int i = 0; i < 10; i++){
               System.out.println(Thread.currentThread().getName() + " 还活着哟");
               try{
                   Thread.sleep(1000);
               }catch(InterruptedException e){
                   e.printStackTrace();
               }
           }

            System.out.println(Thread.currentThread().getName() + " 我将死去");
        },"kiku线程");


        System.out.println(thread.getName() + " ID:" + thread.getId());
        System.out.println(thread.getName() + " 名称：" + thread.getName());
        System.out.println(thread.getName() + " 状态：" + thread.getState());
        System.out.println(thread.getName() + " 优先级：" + thread.getPriority());
        System.out.println(thread.getName() + " 后台线程：" + thread.isDaemon());
        System.out.println(thread.getName() + " 是否活着：" + thread.isAlive());
        System.out.println(thread.getName() + " 是否被中断：" + thread.isInterrupted());

        thread.start();

//        while(thread.isAlive()){
//            System.out.println(thread.getName() + " 状态：" + thread.getState());
//        }
        System.out.println(thread.getName() + " 状态：" + thread.getState() + " 后台线程：" + thread.isDaemon());
    }
}
